import VirtualEditableTable from './src/VirtualEditableTable.vue'
import VirtualEditableTableColumn from './src/VirtualEditableTableColumn.vue'

export { VirtualEditableTable, VirtualEditableTableColumn }
export default { VirtualEditableTable, VirtualEditableTableColumn }

export interface VirtualEditableTableInstance {
  // 重新计算所有表格项的高度
  recalculateAllHeights: () => void
  // 强制更新某一项的高度
  forceItemUpdate: (item: any) => void
  // 检查行是否处于编辑状态
  isEditByRow: (row: any) => boolean
  // 检查行是否有未保存的变化
  isUpdateByRow: (row: any, field?: string) => boolean
  // 获取父节点
  getParentRow: (row: any) => any | null
  // 根据ID获取行
  getRowById: (id: string | number) => any | null
  // 滚动到指定行
  scrollToRow: (row: any) => void
  // 设置当前行，添加高亮样式
  setCurrentRow: (row: any) => void
  // 设置所有树节点的展开状态
  setAllTreeExpand: (expand: boolean) => void
  // 设置单个节点的展开状态
  setTreeExpand: (row: any, expand: boolean) => void
  // 保存指定行的编辑
  saveRow: (row: any) => Promise<void>
  // 取消指定行的编辑
  cancelEdit: (row: any) => void
  // 开始编辑指定行
  startEdit: (row: any, field?: string) => void
}

export interface EditConfig {
  trigger: 'contenteditable' | 'dblclick' | 'manual'
  mode: 'row' | 'cell'
  showInsertStatus?: boolean
  autoClear?: boolean
  debounceTime?: number
}

export interface SaveAdapter {
  editRow: (row: any) => Promise<any>
  addRow?: (row: any) => Promise<any>
  deleteRow?: (row: any) => Promise<any>
}

export interface RowConfig {
  keyField: string
  height?: number | string
  minHeight?: number
}
